apiVersion: v1
kind: ServiceAccount
metadata:
  name: nfs-client-provisioner
  namespace: kube-system

---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: run-nfs-client-provisioner
subjects:
  - kind: ServiceAccount
    name: nfs-client-provisioner
    namespace: kube-system 
roleRef:
  kind: ClusterRole
  name: cluster-admin
  apiGroup: rbac.authorization.k8s.io

---
kind: Deployment
apiVersion: apps/v1
metadata:
  name: {{ storage_nfs_provisioner_name }}
  namespace: kube-system
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: {{ storage_nfs_provisioner_name }}
  template:
    metadata:
      labels:
        app: {{ storage_nfs_provisioner_name }}
    spec:
      serviceAccountName: nfs-client-provisioner
      containers:
      - name: nfs-client-provisioner
        image: {{registry_prefix}}:{{registry_port}}/quay.io/external_storage/nfs-client-provisioner:v3.1.0-k8s1.11
        imagePullPolicy: IfNotPresent
        volumeMounts:
          - name: nfs-client-root
            mountPath: /persistentvolumes
        env:
          - name: PROVISIONER_NAME
            value: {{ storage_nfs_provisioner_name }}
          - name: NFS_SERVER
            value: {{ storage_nfs_server }}
          - name: NFS_PATH
            value: {{ storage_nfs_server_path}}
      volumes:
        - name: nfs-client-root
          nfs:
            server: {{ storage_nfs_server }}
            path: {{ storage_nfs_server_path }}

---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: {{ storageClassName }}
  annotations:
    storageclass.kubernetes.io/is-default-class: true
provisioner: {{ storage_nfs_provisioner_name }}

